<!-- <div class="fd-payment">
  <h2>分店支付信息</h2>
  <div class="fd-con">
    
  </div>
</div> -->
<div class="ad-box rech-s fd-payment">
  <%= form_for([:admin, @studio], html: { multipart: true}) do |f| %>
    <%= hidden_field_tag :company_name, params[:company_name] %>
    <div class="account-infor">
      <h3>
        <span>充值分店信息</span>
      </h3>
      <div class="rech-studio">
        <ul class="clearfix" id="rechBox">
           <li>
              <input type="text" class="ad-pname" placeholder="请输入分店名称" name="studio[name]" id="studio_name">
                <div class="rey-con">
                  <span class="reduce-year"></span>
                  <input type="text" name="duration" id="duration" class="rech-year" onkeyup="intNum(this)">
                  <em>年</em>
                  <span class="plus-year"></span>
                </div>
               <!--  <div class="btn-sc remove_tag">删除</div> -->
          </li>
        </ul>
          <div class="ad-pcon clearfix">
               <input type="text" class="ad-pname" placeholder="请输入分店名称" name="studios_name[]">
                <div class="rey-con">
                  <span class="reduce-year"></span>
                  <input type="text" class="rech-year" onkeyup="intNum(this)" name="studios_duration[]">
                  <em>年</em>
                  <span class="plus-year"></span>
                </div>
                <div class="btn-sc" id="add_studio">添加</div>
          </div>
      </div>
    </div>
    <div>
      <div class="re-year clearfix">
        <b>支付方式:</b>
        <div class="rey-box">
          <div class="rey-con">
            <input class="p-radio" type="radio" name="recharge">
            <div class="ra-btn">
              <span></span>
            </div>
            <em>支付宝</em>
          </div>
          <div class="rey-con">
            <input class="p-radio" type="radio" name="recharge">
            <div class="ra-btn">
              <span></span>
            </div>
            <em>微信</em>
          </div>
        </div>
      </div>
      <div class="re-year re-z clearfix">
        <b>总计:</b>
        <em>1000</em>
        <span>元（单家工作室）x</span>
        <em>1</em>
        <span>年x</span>
        <em>2</em>
        <span>家工作室=</span>
        <em>2000</em>
        <span>元</span>
      </div>
      <div class="re-year re-b clearfix">
        <span>如需发票，付款后可以直接在线索取发票，我们提供正规的增值税普通发票并会按照你提供的地址快递邮寄过去（包邮费）</span>
      </div>
    </div>
    <%= f.submit "立即支付", class: "com-sbtnb"%>
    
  <% end %>
</div>
<script src="/assets/js/common-list.js"></script>
<script>
//增加分店
updYear();
$(".rey-box .ra-btn").on("click", function() {
  $(".rey-con .ra-btn").removeClass("ra-checked");
  $(this).addClass("ra-checked");
  $(this).prev("input").prop("checked", true);
});
$('.ad-pcon #add_studio').click(function(){
  $('#rechBox').
    append("<li><input type='text' class='ad-pname' name='studios_name[]' placeholder='请输入分店名称' value='" + $('.ad-pcon .ad-pname').val() + "'><div class='rey-con'><span class='reduce-year'></span><input type='text' class='rech-year' name='studios_duration[]' onkeyup='intNum(this)' value='" + $('.ad-pcon .rech-year').val() + "'><em>年</em><span class='plus-year'></span></div><div class='btn-sc remove_tag'>删除</div></li>");
    $('.ad-pcon .ad-pname').val("");
    $('.ad-pcon .rech-year').val("");
    $('.remove_tag').click(function() {
      $(this).parent().remove();
    });
    updYear();
}); 
function updYear() {
  $(".reduce-year").unbind("click");
  $(".plus-year").unbind("click");
  $(".reduce-year").on("click", function() {
    if ($(this).parent().find("input").val() == "") {
      $(this).parent().find("input").val(0);
    } else {
      if (Number($(this).parent().find("input").val()) > 0) {
        $(this).parent().find("input").val(Number($(this).parent().find("input").val()) - 1);
      };
    }
  });
  $(".plus-year").on("click", function() {
    if ($(this).parent().find("input").val() == "") {
      $(this).parent().find("input").val(1);
    } else {
     $(this).parent().find("input").val(Number($(this).parent().find("input").val()) + 1);
    }
  });
}
</script>
